//
//  ISCallVoiceCollectionViewCell.m
//  iPhoneSafety
//
//  Created by dlon 2018/12/31.
//  Copyright © 2018年 com.li.ding. All rights reserved.
//

#import "ISCallVoiceCollectionViewCell.h"
#import "NWLazyProperty.h"
#import <Masonry/Masonry.h>
#import "UIColor+NWHex.h"


@interface ISCallVoiceCollectionViewCell()

@end

@implementation ISCallVoiceCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.slider];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView);
            make.left.equalTo(self.contentView).offset(17.f);
        }];
        
        [self.slider mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView);
            make.right.equalTo(self.contentView).offset(-18.f);
            make.left.equalTo(self.titleLabel.mas_right).offset(77.f);
            make.height.equalTo(self.contentView);
        }];
    }
    return self;
}

- (void)changge {
    if (self.actionBlock) {
        self.actionBlock(self.slider.value);
    }
}

#pragma mark - set & get

NWLazyPropertyWithInit(UILabel, titleLabel, {
    _titleLabel.font = [UIFont systemFontOfSize:17.f];
    _titleLabel.textColor = [UIColor nw_colorWithHex:0x222222];
})

- (UISlider *)slider {
    if (!_slider) {
        _slider = [UISlider new];
        _slider.minimumTrackTintColor = [UIColor nw_colorWithHex:0x0084FF];
        _slider.maximumTrackTintColor = [UIColor nw_colorWithHex:0xB8C2D1];
        _slider.contentMode = UIViewContentModeCenter;

        [_slider addTarget:self action:@selector(changge) forControlEvents:UIControlEventValueChanged];
    }
    return _slider;
}


@end
